home *** CD-ROM | disk | FTP | other *** search
/ Nebula 2 / Nebula Two.iso / SourceCode / Palettes / TTools / TToolsPalette / TBinderList.subproj / TDataSourceConnector.m < prev   
Encoding:
Text File  |  1995-06-12  |  1.8 KB  |  98 lines

  1. /* TDataSourceConnector.m
  2.  * Written By:  Thomas Burkholder
  3.  *
  4.  * You may freely copy, distribute, and reuse the code in this example.
  5.  * NeXT disclaims any warranty of any kind, expressed or  implied, as to its
  6.  * fitness for any particular use.
  7.  */
  8.  
  9. #import "TDataSourceConnector.h"
  10. #import "TBinderList.h"
  11.  
  12. @implementation TDataSourceConnector
  13.  
  14. - init
  15. {
  16.     [super init];
  17.     return self;
  18. }
  19.  
  20. - free
  21. {
  22.     // Commented out because isTestingInterface doesn't work properly...
  23.     // Note that this introduces the following behaviour:
  24.     // 1.  set dataSource, delete it, save or test interface,
  25.     //     you have ref to freed object in TBinderList.
  26.     // Workaround:  in the write: method of TConnector, look for a
  27.     // datasourceconnector - not finding one, set source of TBinderList to
  28.     // nil.  Or use a documentcontroller to make the change before the save
  29.     // is done.
  30.     if (([NXApp respondsTo:@selector(isTestingInterface)]) &&
  31.         ([NXApp isTestingInterface])) {
  32. //        [source setDataSource:nil];
  33.     }
  34.     
  35.     return [super free];
  36. }
  37.  
  38. - setSource:anObject
  39. {
  40.     source = anObject;
  41.     return self;
  42. }
  43.  
  44. - setDestination:anObject
  45. {
  46.     destination = anObject;
  47.     return self;
  48. }
  49.  
  50. - source
  51. {
  52.     return source;
  53. }
  54.  
  55. - destination
  56. {
  57.     return destination;
  58. }
  59.  
  60. - establishConnection
  61. {
  62.     return self;
  63. }
  64.  
  65. - nibInstantiate
  66. {
  67.     // we cheat a bit; the object is archived with this value as dataSource
  68.     [source setDataSource:destination];
  69.  
  70.     return self;
  71. }
  72.  
  73. - renewObject:old to:new
  74. {
  75.     if (old == source)
  76.         source = new;
  77.     else if (old == destination)
  78.         destination = new;
  79.     return self;
  80. }
  81.  
  82. - read:(NXTypedStream *)stream
  83. {
  84.     [super read:stream];
  85.     source = NXReadObject(stream);
  86.     destination = NXReadObject(stream);
  87.     return self;
  88. }
  89.  
  90. - write:(NXTypedStream *)stream
  91. {
  92.     [super write:stream];
  93.     NXWriteObject(stream,source);
  94.     NXWriteObject(stream,destination);
  95.     return self;
  96. }
  97.  
  98. @end